<template>
  <el-dialog
    class="eldialog el-dialog-m0"
    :visible.sync="visible"
    :title="title"
    :close-on-click-modal="false"
    append-to-body
    top="2vh"
    width="100%"
    :close-on-press-escape="false"
    element-loading-text="数据加载中"
    v-loading="loading"
  >
    <el-form :inline="true" :model="msgData" :rules="rules" ref="msgData" class="demo-form-inline">
      <el-row>
        <el-col :span="24" align="center">
          <el-form-item prop="dw">
            <el-input :disabled="flag"  maxlength="30" size="small" placeholder="请输入单位名称"
                      v-model="msgData.dw">
            </el-input>
          </el-form-item>
          <span style="font-size: 28px;line-height: 32px;font-weight: 900;height: 50px;">2023年度年轻干部配备提升计划表</span>
          <el-button style="margin-right: 30px;margin-top: 10px;float: right" type="primary" plain @click="downZip"
          >&nbsp;导出<i class="el-icon-upload el-icon--right"></i>
          </el-button>

          <el-button v-if="btType === '2'" style="margin-right: 10px;margin-top: 10px;float: right" type="primary"
                     icon="el-icon-edit" plain
                     @click="auditTable()" :disabled="shztBegin === '1' || shztGHB === '1'">&nbsp;审核
          </el-button>
          <el-button v-if="btType === '2' && (shztBegin === '1'||shztGHB === '1')"
                     style="margin-right: 10px;margin-top: 10px;float: right" type="primary" icon="el-icon-edit" plain
                     @click="flag = false;shztBegin = '0';shztGHB = '0'">&nbsp;修改
          </el-button>
          <el-button v-if="role == '系统管理员'" style="margin-right: 10px;margin-top: 10px;float: right" type="primary"
                     icon="el-icon-edit" plain
                     @click="save('msgData')">&nbsp;保存
          </el-button>
          <el-button v-else style="margin-right: 10px;margin-top: 10px;float: right" type="primary" icon="el-icon-edit"
                     plain
                     @click="save('msgData')" :disabled="flag">&nbsp;保存
          </el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-form-item label="填表人：" prop="tbr">
          <el-input :disabled="flag"  maxlength="15" size="small" placeholder="请输入填表人姓名"
                    v-model="msgData.tbr">
          </el-input>
        </el-form-item>
        <el-form-item label="联系方式：" prop="lxfs">
          <el-input :disabled="flag" size="small" placeholder="请输入联系方式"
                    oninput="if(value.length>15)value=value.slice(0,15)"
                    v-model="msgData.lxfs">
          </el-input>
        </el-form-item>
        <el-form-item  label="表格盖章扫描:" >
          <div v-if="excelData.excelFile == ''">
            <el-upload style="margin-bottom: 5px"   class="upload-demo"
                       accept=".pdf"
                       :action="fileServerPath"
                       :show-file-list="false"
                       :on-success="(response, file, fileList)=> excelFileUpload(response, file, fileList)"
                       :before-upload="beforeAvatarUpload"
                       :multiple="false"
                       :disabled="flag">
              <el-button :disabled="flag" size="small" type="primary">
                上传<i class="el-icon-upload el-icon--right"></i>
              </el-button>
            </el-upload>
          </div>
          <div v-else-if="excelData.excelFile != '' && flag == true">
            <el-link   type="primary"  @click="showFile(excelData.excelFile)">
              {{excelData.excelFileName}}
            </el-link>
          </div>
          <div v-else>
            <el-upload style="margin-bottom: 5px"   class="upload-demo"
                       accept=".pdf"
                       :action="fileServerPath"
                       :show-file-list="false"
                       :on-success="(response, file, fileList)=> excelFileUpload(response, file, fileList)"
                       :before-upload="beforeAvatarUpload"
                       :multiple="false"
                       :disabled="flag">
              <a>{{excelData.excelFileName}}</a>
            </el-upload>
          </div>
        </el-form-item>
      </el-row>
    </el-form>
    <el-row>
      <vxe-table style="width: 100%"
                border
                :data="pbtsjhData">
        <vxe-colgroup
          title="市级党政工作部门正职"
          align="center"
          min-width="100%">
          <vxe-colgroup
            title="职数及岗位情况"
            align="center">
            <vxe-column
              title="批复职数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.sjdzZsgwPfzs = $event.target.value" v-model="scope.row.sjdzZsgwPfzs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-column
              align="center">
              <template slot="header">      
                <div>2022年底</div>
                <div>配备数量</div>
              </template>
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.sjdzZsgwPbsl = $event.target.value" v-model="scope.row.sjdzZsgwPbsl">
                </el-input>
              </template>
            </vxe-column>
            <vxe-column
              align="center">
              <template slot="header">      
                <div>年内预计</div>
                <div>可调整岗位数量</div>
              </template>
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.sjdzZsgwYjtzsl = $event.target.value" v-model="scope.row.sjdzZsgwYjtzsl">
                </el-input>
              </template>
            </vxe-column>
          </vxe-colgroup>
          <vxe-colgroup
            title="截至2022年底配备情况"
            align="center">
            <vxe-column
              align="center">
              <template slot="header">      
                <div>部门正职</div>
                <div>平均年龄（岁）</div>
              </template>
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*/g, '$1')"
                          @blur="scope.row.sjdzPbqkPjnl = $event.target.value"  v-model="scope.row.sjdzPbqkPjnl">
                </el-input>
              </template>
            </vxe-column>
            <vxe-colgroup
              title="41岁以下部门正职干部"
              align="center">
              <vxe-column
                title="人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.sjdzPbqk41nrs = $event.target.value" v-model="scope.row.sjdzPbqk41nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="2023年内超41岁人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.sjdzPbqk41crs = $event.target.value" v-model="scope.row.sjdzPbqk41crs">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
          </vxe-colgroup>
          <vxe-colgroup
            title="2023年配备目标"
            align="center">
            <vxe-colgroup
              title="年内计划补充部门正职干部"
              align="center">
              <vxe-column
                title="人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.sjdzPbmbBcrs = $event.target.value" v-model="scope.row.sjdzPbmbBcrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="其中41岁以下人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.sjdzPbmbBc41nrs = $event.target.value"  v-model="scope.row.sjdzPbmbBc41nrs">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
            <vxe-column
              title="年底41岁以下部门正职干部人数计划达到"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.sjdzPbmb41nrs = $event.target.value"   v-model="scope.row.sjdzPbmb41nrs">
                </el-input>
              </template>
            </vxe-column>
          </vxe-colgroup>
        </vxe-colgroup>
        <vxe-colgroup
          title="县（市、区）党政正职"
          align="center"
          min-width="100%">
          <vxe-colgroup
            title="职数及配备情况"
            align="center">
            <vxe-column
              title="批复职数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.qxdzPbqkPfzs = $event.target.value"    v-model="scope.row.qxdzPbqkPfzs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-column
              align="center">
              <template slot="header">      
                <div>2022年底</div>
                <div>配备41岁以下干部</div>
              </template>
              <vxe-column
                title="人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.qxdzPbqk41nrs = $event.target.value"  v-model="scope.row.qxdzPbqk41nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="占比（%）"
                align="center">
                <template slot-scope="scope">
                  <el-input disabled
                            v-model="scope.row.qxdzPbqk41rszb">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-column>
          </vxe-colgroup>
          <vxe-colgroup
            title="2023年配备目标"
            align="center">
            <vxe-column
              align="center">
              <template slot="header">      
                <div>年内计划补充</div>
                <div>41岁以下干部人数</div>
              </template>
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.qxdzPbmbBc41nrs = $event.target.value"  v-model="scope.row.qxdzPbmbBc41nrs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-column
              title="年底41岁以下干部人数计划达到"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.qxdzPbmb41nrs = $event.target.value" v-model="scope.row.qxdzPbmb41nrs">
                </el-input>
              </template>
            </vxe-column>
          </vxe-colgroup>
        </vxe-colgroup>
      </vxe-table>
    </el-row>
    <el-row>
      <vxe-table style="width: 100%"
                :data="pbtsjhData"
                border>
        <vxe-colgroup
          title="县级党政领导班子"
          align="center"
          min-width="100%">
          <vxe-colgroup
            title="职数及配备情况"
            align="center">
            <vxe-column
              title="批复职数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.xjldPbqkPfzs = $event.target.value" v-model="scope.row.xjldPbqkPfzs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-colgroup
              title="2022年底配备41岁以下干部"
              align="center">
              <vxe-column
                title="人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xjldPbqk41nrs = $event.target.value" v-model="scope.row.xjldPbqk41nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="占比（%）"
                align="center">
                <template slot-scope="scope">
                  <el-input disabled
                            v-model="scope.row.xjldPbqkZb">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="2023年内超41岁人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xjldPbqk41crs = $event.target.value" v-model="scope.row.xjldPbqk41crs">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
          </vxe-colgroup>
          <vxe-colgroup
            title="2023年配备目标"
            align="center">
            <vxe-column
              title="年内计划补充41岁以下干部人数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.xjldPbmbBc41nrs = $event.target.value" v-model="scope.row.xjldPbmbBc41nrs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-colgroup
              title="年底41岁以下干部人数"
              align="center">
              <vxe-column
                title="计划达到"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xjldPbmb41nrs = $event.target.value" v-model="scope.row.xjldPbmb41nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="占比（%）"
                align="center">
                <template slot-scope="scope">
                  <el-input disabled
                            v-model="scope.row.xjldPbmbZb">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
          </vxe-colgroup>
        </vxe-colgroup>
        <vxe-colgroup
          title="乡镇（街道）党政正职"
          align="center"
          min-width="100%">
          <vxe-colgroup
            title="职数及配备情况"
            align="center">
            <vxe-column
              title="批复职数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.xzdzPbqkPfzs = $event.target.value"  v-model="scope.row.xzdzPbqkPfzs">
                </el-input>
              </template>
            </vxe-column>
            <vxe-colgroup
              title="2022年底配备36岁以下干部"
              align="center">
              <vxe-column
                title="人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xzdzPbqk36nrs = $event.target.value" v-model="scope.row.xzdzPbqk36nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="占比（%）"
                align="center">
                <template slot-scope="scope">
                  <el-input disabled
                            v-model="scope.row.xzdzPbqkZb">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="2023年内超36岁人数"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xzdzPbqk36crs = $event.target.value"  v-model="scope.row.xzdzPbqk36crs">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
          </vxe-colgroup>
          <vxe-colgroup
            title="2023年配备目标"
            align="center">
            <vxe-colgroup
              title="年内计划补充36岁以下干部人数"
              align="center">
              <template slot-scope="scope">
                <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                          @blur="scope.row.xzdzPbmbBc36nrs = $event.target.value" v-model="scope.row.xzdzPbmbBc36nrs">
                </el-input>
              </template>
            </vxe-colgroup>
            <vxe-colgroup
              title="年底36岁以下干部人数"
              align="center">
              <vxe-column
                title="计划达到"
                align="center">
                <template slot-scope="scope">
                  <el-input :disabled="flag" onkeyup="value=value.replace(/^\D*(\d*).*/g, '$1')"
                            @blur="scope.row.xzdzPbmb36nrs = $event.target.value" v-model="scope.row.xzdzPbmb36nrs">
                  </el-input>
                </template>
              </vxe-column>
              <vxe-column
                title="占比（%）"
                align="center">
                <template slot-scope="scope">
                  <el-input disabled
                            v-model="scope.row.xzdzPbmbZb">
                  </el-input>
                </template>
              </vxe-column>
            </vxe-colgroup>
          </vxe-colgroup>
        </vxe-colgroup>
      </vxe-table>
    </el-row>
    <el-row>
      <vxe-table style="width: 100%"
                :data="tsqksmData"
                border>
        <vxe-column
          align="center"
          title="特殊情况说明"
        >
          <template slot-scope="scope">
            <el-input :disabled="flag" maxlength="300" placeholder="请输入特殊情况说明" v-if="scope.row.type == 1" v-model="scope.row.tsqk"
                      type="textarea" :rows="3" :autosize="{ minRows: 3, maxRows: 6 }">
            </el-input>
            <span v-if="scope.row.type == '2' ">
              <div  >附件：
                <div v-for="(item,i) in scope.row.tsqkFileName" style="margin-bottom: 5px">
                  <el-link   type="primary"  @click="showFile(scope.row.tsqkFile[i])">
                    {{i + 1}} 、 {{item}}
                  </el-link>
                  <el-button :disabled="flag" style="margin-left: 20px" type="danger"
                             icon="el-icon-delete" circle size="mini"
                             @click="delFileByTsqk(i)">
                  </el-button>
                </div>
              </div>
              <el-upload style="margin-bottom: 5px"   class="upload-demo"
                         accept=".pdf"
                         :action="fileServerPath"
                         :show-file-list="false"
                         :on-success="(response, file, fileList)=> fileUpload(response, file, fileList)"
                         :before-upload="beforeAvatarUpload"
                         :multiple="false"
                         :disabled="flag"
              >
                <el-button :disabled="flag" size="small" type="primary" >
                    特殊情况附件<i class="el-icon-upload el-icon--right"></i>
                </el-button>
              </el-upload>
            </span>
          </template>
        </vxe-column>

      </vxe-table>
    </el-row>
    <archiveFile-show ref="dialogarchiveFile"/>
  </el-dialog>
</template>

<script>

  /*方法引用*/
  import {getList2023, save2023,downLsqk2023,auditTable} from '@/api/young/evaluation/infoFilling/infoFilling.js'
  import store from '@/store'
  import webapp from "@/config/webapp";
  import archiveFileShow from "@/views/young/evaluation/archiveFile";

  export default {
    name: "pbtsjhTable2023_ds",
    components: {'archiveFile-show': archiveFileShow,},
    data() {
      return {
        title: '配备提升计划表',
        visible: false,
        pdfUrl: '',
        heightY: window.innerHeight - 90 + 'px',
        heightZ: window.innerHeight - 360 + 'px',
        widthY: window.innerWidth / 2 - 50 + 'px',

        loading: false,
        flag:false,
        role:'',
        btType:'',
        shztBegin:'',
        shztGHB:'',
        pbtsjhData: [],
        tsqksmData:[],//特殊情况说明数据
        msgData: {
          "id": "",
          "dw": "",
          "tbr": "",
          "lxfs": "",
          "taskId": "",
          "sjd": ""
        },
        excelData: {
          "excelFile":"",
          "excelFileName":"",
        },
        options: [{
          value: '1',
          label: '上升'
        }, {
          value: '0',
          label: '持平'
        }, {
          value: '-1',
          label: '下降'
        }],
        taskId: '',
          fileServerPath: webapp.GHB_URL+'/evaluation/excel/fileUpload',
        rules: {
          tbr: [
            {required: true, message: '请输入填表人姓名', trigger: 'blur'}
          ],
          lxfs: [
            {required: true, message: '请输入联系方式', trigger: 'blur'}
          ],
          dw: [
            {required: true, message: '请输入单位名称', trigger: 'blur'}
          ],
        },
        reg : /^([1-9][0-9]*|0)(\.[0-9]*[1-9])?$/,
      }
    },
    watch : {
      pbtsjhData: {
        handler: function() {
          this.pbtsjhData.forEach(item =>{
            //乡镇年底36岁以下占比
            if (item.xzdzPbmb36nrs != '' && item.xzdzPbmb36nrs != null && this.reg.test(item.xzdzPbmb36nrs)
              && item.xzdzPbqkPfzs != '' && item.xzdzPbqkPfzs != null && item.xzdzPbqkPfzs != 0 &&
              this.reg.test(item.xzdzPbqkPfzs)) {
              item.xzdzPbmbZb = ((item.xzdzPbmb36nrs / item.xzdzPbqkPfzs) * 100).toFixed(1) + '%';
            }else {
              if(!item.xzdzPbmbZb){
                item.xzdzPbmbZb = '0.0%'
              }

            }
            //乡镇年底配备36岁以下占比
            if (item.xzdzPbqk36nrs != '' && item.xzdzPbqk36nrs != null && this.reg.test(item.xzdzPbqk36nrs)
              && item.xzdzPbqkPfzs != '' && item.xzdzPbqkPfzs != null && item.xzdzPbqkPfzs != 0 && this.reg.test(item.xzdzPbqkPfzs)) {
              item.xzdzPbqkZb = ((item.xzdzPbqk36nrs / item.xzdzPbqkPfzs) * 100).toFixed(1)+ '%';
            }else {
              if(!item.xzdzPbqkZb){
                item.xzdzPbqkZb = '0.0%'
              }
            }
            //领导班子年底41岁以下占比
            if (item.xjldPbmb41nrs != '' && item.xjldPbmb41nrs != null && this.reg.test(item.xjldPbmb41nrs) && this.reg.test(item.xjldPbqkPfzs)
              && item.xjldPbqkPfzs != '' && item.xjldPbqkPfzs != null && item.xjldPbqkPfzs != 0) {
              item.xjldPbmbZb = ((item.xjldPbmb41nrs / item.xjldPbqkPfzs) * 100 ).toFixed(1)+ '%';
            }else {
              if(!item.xjldPbmbZb){
                item.xjldPbmbZb = '0.0%'
              }
            }
            //领导班子年底配备41岁以下占比
            if (item.xjldPbqk41nrs != '' && item.xjldPbqk41nrs != null && this.reg.test(item.xjldPbqk41nrs) && this.reg.test(item.xjldPbqkPfzs)
              && item.xjldPbqkPfzs != '' && item.xjldPbqkPfzs != null && item.xjldPbqkPfzs != 0) {
              item.xjldPbqkZb = ((item.xjldPbqk41nrs / item.xjldPbqkPfzs) * 100).toFixed(1)+ '%';
            }else {
              if(!item.xjldPbqkZb){
                item.xjldPbqkZb = '0.0%'
              }
            }
            //县级正职年底配备36岁以下占比
            if (item.qxdzPbqkPfzs != '' && item.qxdzPbqkPfzs != null && this.reg.test(item.qxdzPbqkPfzs) && this.reg.test(item.qxdzPbqk41nrs)
              && item.qxdzPbqk41nrs != '' && item.qxdzPbqk41nrs != null && item.qxdzPbqkPfzs != 0) {
              item.qxdzPbqk41rszb = ((item.qxdzPbqk41nrs / item.qxdzPbqkPfzs) * 100).toFixed(1)+ '%';
            }else {
              if(!item.qxdzPbqk41rszb){
                item.qxdzPbqk41rszb = '0.0%'
              }
            }
          });
        },
        deep: true
      }
    },
    methods: {
      async initShow(task,role,shztGHB,type) {
        this.task =task;
        this.btType = type;
        this.shztGHB = shztGHB;
        this.role = role;
        this.taskId = task.id;
        this.visible = true;
        this.msgData = {};
        this.excelData.excelFileName = "";
        this.excelData.excelFile = "";
        this.pbtsjhData = [];
        const params = {
          'taskId': task.id,
          'type': '1'
        };
        this.loading = true;
        getList2023(params).then((data) => {
          if (data.type) {
            if (data.resultdata.bt) {
              this.msgData = data.resultdata.bt
              this.shztBegin = data.resultdata.bt.shztBegin
            }
            if (data.resultdata.list) {
              this.pbtsjhData = data.resultdata.list
            }
            if (data.resultdata.tsjhList) {
              this.tsqksmData = data.resultdata.tsjhList
            }
            if (data.resultdata.excelList) {
              this.excelData.excelFile = data.resultdata.excelList[0].excelFile;
              this.excelData.excelFileName = data.resultdata.excelList[0].excelFileName;
            }
            this.loading = false;
          } else {
            this.$message.error(data.message)
          }
          if (this.shztGHB == '1' || this.shztBegin == '1'){
            this.flag = true;
          }else {
            var jgid= JSON.parse(sessionStorage.getItem(`userInfo`)).organizeId
            if (jgid !== task.dwBianma) {
              if (role == '系统管理员'||role.indexOf('干部一处')>-1||role.indexOf('干部二处')>-1||
                role.indexOf('干部三处')>-1||role.indexOf('干部四处')>-1||role.indexOf('干部五处')>-1) {
                this.flag = true;
              }else {
                this.flag = false;
              }
            }else {
              this.flag = false;
            }
          }
        })
      },

      //保存
      save(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$confirm('是否保存?', '操作提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.msgData.taskId = this.taskId;
              this.msgData.sjd = 'begin'
              this.pbtsjhData.forEach((item) => {
                item.taskId = this.taskId;
              });
              const params = {
                'bt': this.msgData,
                'excelData': this.excelData,
                'data': this.pbtsjhData,
                "tsqk" : this.tsqksmData,
                'type': '1',
                  "userInfo": JSON.parse(sessionStorage.getItem(`userInfo`)),
              };
              this.loading = true;
              save2023(params).then((data) => {
                console.log(data.result)
                if (data.result) {
                  this.loading = false;
                  this.$message.success('保存成功!')
                  this.visible = false;
                } else {
                  this.loading = false;
                  this.$message.error(data.message)
                }
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消保存!'
              });
            });
          }
        });
      },
      //审核
      auditTable(){
        this.$confirm('是否审核通过?', '操作提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.msgData.taskId = this.taskId;
          this.msgData.sjd = 'begin'
           const params = {
            'id': this.msgData.id,
            'task': this.task,
            'type': '1'
          };
          this.loading = true;
          auditTable(params).then((data) => {
            if (data.result) {
              this.loading = false;
              this.$message.success('审核通过!')
              this.visible = false;
            } else {
              this.loading = false;
              this.$message.error(data.message)
            }
          }).catch(res => {
              this.$message.error(res)
              this.loading = false;
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消审核!'
          });
        });
      },

      //附件上传函数
      fileUpload(response, file, fileList) {
        this.tsqksmData[1].tsqkFile.push(response.url);
        this.tsqksmData[1].tsqkFileName.push(file.name);
      },

      //表格扫描附件上传函数
      excelFileUpload(response, file, fileList) {
        this.excelData.excelFile = response.url;
        this.excelData.excelFileName = file.name;
      },
      //文件格式约束
      beforeAvatarUpload(file) {
        console.log(file,'beforeFile')
        const isPDF = file.name.substring(file.name.lastIndexOf('.') + 1) === 'pdf';
        const fileSize = file.size/1024
        if (fileSize > 2*1024){
          this.$message.error('上传附件材料不能大于2M!');
          return false
        }
        if (!isPDF) {
          this.$message.error('上传的附件材料后缀只能是.pdf的文件格式!');
        }
        return isPDF;
      },
      //文件预览
      showFile(fileurl) {
        this.$nextTick(() => {
          this.$refs.dialogarchiveFile.initShow(fileurl)
        })
      },
      delFileByTsqk(sort){
        this.$confirm('是否删除该附件?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.tsqksmData[1].tsqkFile.splice(sort,1);
          this.tsqksmData[1].tsqkFileName.splice(sort,1);
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
        //下载
        downZip(){
            const month= new Date().getMonth() + 1;
            const params = {
                taskId: this.taskId,
                type : 1,
                dw : this.msgData.dw,
              fileName:this.msgData.dw+"年初制定(" +
                new Date().getFullYear() +"年"+month+ "月).zip"
            }
            this.$confirm('是否下载?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.pageLoading = true;
                downLsqk2023(params).then(result => {
                    this.pageLoading = false;
                    // this.$alert('成功')
                })
            })
        },
    }
  }
</script>

<style scoped>
   >>>.el-input.is-disabled .el-input__inner{
    color: #606266;
  }
  /*调整表格文字*/
  >>>.vxe-header--column .vxe-cell--title{
    font-size: 14px;
    font-weight: normal;
    color:#000;
  }
  >>>.vxe-header--row{
    background:#fff;
  }
  
</style>
